﻿using UnityEngine;
using System.Collections;

public class Shockwave : MonoBehaviour {
	float t = 0;
	float size = 0;
	public float growthTime = 1.5f;
	public float maxSize = 6f;
	public float waitBeforeDestroy = 1f;
	private GameObject player;
	// Use this for initialization
	void Start () 
	{
		player = GameObject.FindGameObjectWithTag("Player");
			transform.localScale = new Vector3(0f, 0f, 0f);
	}
	
	// Update is called once per frame
	void Update () 
	{
	 	t += Time.deltaTime / growthTime;
		size = Mathf.Lerp(0f,maxSize, t);
		transform.localScale = new Vector3(size, .01f, size);
		player.transform.position = new Vector3(player.transform.position.x, player.transform.position.y +.0001f, 0f);
		Invoke("Destroy", growthTime+waitBeforeDestroy);

	}
	void Destroy()
	{
		Destroy(gameObject);
	}
}
